home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 28
/
Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso
/
Aminet
/
dev
/
lang
/
fpc09905c.lha
/
fpc
/
units
/
strings.pp
< prev
next >
Wrap
Text File
|
1998-09-21
|
20KB
|
644 lines
{
$Id: strings.pp,v 1.2 1998/07/01 14:29:42 carl Exp $
This file is part of the Free Pascal run time library.
Copyright (c) 1997 by Carl-Eric Codere,
member of the Free Pascal development team.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
Unit Strings;
{*********************************************************************}
{ Strings unit, 100% portable. }
{- COMPILING INFORMATION ---------------------------------------------}
{ The only difference between this unit and the one supplied with }
{ Turbo Pascal 7.01, are that StrLen returns a longint, and the }
{ routines requiring a length now use longints instead of words. }
{ This should not influence the behaviour of your programs under }
{ Turbo Pascal. (it will even create better error checking for your }
{ programs). }
{*********************************************************************}
Interface
{*********************************************************************}
{ Returns the number of Characters in Str,not counting the Null }
{ chracter. }
{*********************************************************************}
function StrLen(Str: PChar): longint;
function StrEnd(Str: PChar): PChar;
{*********************************************************************}
{ Description: Move count characters from source to dest. }
{ Do not forget to use StrLen(source)+1 as l parameter to also move }
{ the null character. }
{ Return value: Dest }
{ Remarks: Source and Dest may overlap. }
{*********************************************************************}
function StrMove(Dest,Source : Pchar;l : Longint) : pchar;
function StrCopy(Dest, Source: PChar): PChar;
{*********************************************************************}
{ Input: Source -> Source of the null-terminated string to copy. }
{ Dest -> Destination of null terminated string to copy. }
{ Return Value: Pointer to the end of the copied string of Dest. }
{ Output: Dest -> Pointer to the copied string. }
{*********************************************************************}
function StrECopy(Dest, Source: PChar): PChar;
{*********************************************************************}
{ Copies at most MaxLen characters from Source to Dest. }
{ }
{ Remarks: According to the Turbo Pascal programmer's Reference }
{ this routine performs length checking. From the code of the }
{ original strings unit, this does not seem true... }
{ Furthermore, copying a null string gives two null characters in }
{ the destination according to the Turbo Pascal routine. }
{*********************************************************************}
function StrLCopy(Dest, Source: PChar; MaxLen: Longint): PChar;
{*********************************************************************}
{ Input: Source -> Source of the pascal style string to copy. }
{ Dest -> Destination of null terminated string to copy. }
{ Return Value: Dest. (with noew copied string) }
{*********************************************************************}
function StrPCopy(Dest: PChar; Source: String): PChar;
{*********************************************************************}
{ Description: Appends a copy of Source to then end of Dest and }
{ return Dest. }
{*********************************************************************}
function StrCat(Dest, Source: PChar): PChar;
{*********************************************************************}
{ Description: Appends at most MaxLen - StrLen(Dest) characters from }
{ Source to the end of Dest, and returns Dest. }
{*********************************************************************}
function strlcat(dest,source : pchar;l : Longint) : pchar;
{*********************************************************************}
{ Compares two strings. Does the ASCII value substraction of the }
{ first non matching characters }
{ Returns 0 if both strings are equal }
{ Returns < 0 if Str1 < Str2 }
{ Returns > 0 if Str1 > Str2 }
{*********************************************************************}
function StrComp(Str1, Str2: PChar): Integer;
{*********************************************************************}
{ Compares two strings without case sensitivity. See StrComp for more}
{ information. }
{ Returns 0 if both strings are equal }
{ Returns < 0 if Str1 < Str2 }
{ Returns > 0 if Str1 > Str2 }
{*********************************************************************}
function StrIComp(Str1, Str2: PChar): Integer;
{*********************************************************************}
{ Compares two strings up to a maximum of MaxLen characters. }
{ }
{ Returns 0 if both strings are equal }
{ Returns < 0 if Str1 < Str2 }
{ Returns > 0 if Str1 > Str2 }
{*********************************************************************}
function StrLComp(Str1, Str2: PChar; MaxLen: Longint): Integer;
{*********************************************************************}
{ Compares two strings up to a maximum of MaxLen characters. }
{ The comparison is case insensitive. }
{ Returns 0 if both strings are equal }
{ Returns < 0 if Str1 < Str2 }
{ Returns > 0 if Str1 > Str2 }
{*********************************************************************}
function StrLIComp(Str1, Str2: PChar; MaxLen: Longint): Integer;
{*********************************************************************}
{ Input: Str -> String to search. }
{ Ch -> Character to find in Str. }
{ Return Value: Pointer to first occurence of Ch in Str, nil if }
{ not found. }
{ Remark: The null terminator is considered being part of the string }
{*********************************************************************}
function StrScan(Str: PChar; Ch: Char): PChar;
{*********************************************************************}
{ Input: Str -> String to search. }
{ Ch -> Character to find in Str. }
{ Return Value: Pointer to last occurence of Ch in Str, nil if }
{ not found. }
{ Remark: The null terminator is considered being part of the string }
{*********************************************************************}
function StrRScan(Str: PChar; Ch: Char): PChar;
{*********************************************************************}
{ Input: Str1